/**
 * New node file
 */
var app = angular.module('pollServices', ['ngResource']).
factory('Poll', function($resource) {
	return $resource('polls/:pollId', {}, {
		query: { method: 'GET', params: { pollId: 'polls' }, isArray: true }
	})
}).
factory('socket', function($rootScope) {
	var socket = io.connect();
	return {
		on: function (eventName, callback) {
			socket.on(eventName, function () {  
				var args = arguments;
				$rootScope.$apply(function () {
					callback.apply(socket, args);
				});
			});
		},
		emit: function (eventName, data, callback) {
			socket.emit(eventName, data, function () {
				var args = arguments;
				$rootScope.$apply(function () {
					if (callback) {
						callback.apply(socket, args);
					}
				});
			})
		}
	};
});

//app.service('MapService', function(){
//	
//	this.findaddress = function() {
//    
//		var address = document.getElementById("address").value;
//	    alert("starting address coder...");
//	    $scope.geocoder.geocode( { 'address': address}, function(results, status) {
//	      if (status == google.maps.GeocoderStatus.OK) {
//	    	alert("Status is: " + status);
//	    	$scope.map.setCenter(results[0].geometry.location);
//	        var marker = new google.maps.Marker({
//	            map: $scope.map,
//	            position: results[0].geometry.location
//	        });
//	      } else {
//	        alert("Geocode was not successful for the following reason: " + status);
//	      }
//	    });
//	}
// 
//});

